<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>新增机型addAircraft </title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />

	<style>
		body{
			background:#eeeeee;
		}
		.newPlan{
			background:#ff7777;
		}
		.btnBox{
			width:100%;
			text-align:center;
			margin-top:15px;
		}
		.addAir{
			width:400px;
		}
		.addAir p{
		    margin:0 auto;
			color:#959ca2;
			width:330px;
			height:30px;
			margin-top:15px;
			line-height:30px;
			text-align:right;
		}
		.addAir p input{
			width:200px;
			height:100%;
			margin-left:10px;
			font-family:"微软雅黑";
			font-size:14px;
			padding-left:10px;
		}
		.cancel{
		margin-left:15px;
		background-color:#afb1b0;
		}
	</style>
	<body>
		<div class="addAir">
			<input style='display:none' type='text'  class='id'/>
			<p>机型名称:<input class='val1' type="text"  /><strong style="color:red;">*</strong></p>
			<p>制造商:<input class='val2' type="text"  /><strong style="color:#f1f1f1;">*</strong></p>
			<p>最大承载行李:<input class='val3' type="text"  /><strong style="color:#f1f1f1;">*</strong></p>
			<p>最大座位数:<input class='val4' type="text"  /><strong style="color:#f1f1f1;">*</strong></p>
			<p>机型大小:<input class='val5' type="text"  /><strong style="color:#f1f1f1;">*</strong></p>
			<p>机型宽度:<input class='val6' type="text"  /><strong style="color:#f1f1f1;">*</strong></p>
		</div>
		
		<div class='btnBox'>
			<button class='Dolo_btn sure'>确认</button>
			<button class='Dolo_btn cancel'>取消</button>
		</div>
		
		
	</body>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<!-- 引入my97日期时间控件 -->
		<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>	
		<script type="text/javascript" src="../js/common.js" ></script>
		<script>
		 var id = getHref().id
		 if(id){
			 $(".val1").attr("readonly","readonly").css("background","#f9f5f5")
			 $.get("../Aircft/editPage?id="+id+"&temp="+Math.random(),function(data){
				 data = JSON.parse(data)
				 console.log(data)
				 $(".id").val(data.data.id)
				 $(".val1").val(data.data.model);
				 $(".val2").val(data.data.manufacturer);
				 $(".val3").val(data.data.maxWeight);
				 $(".val4").val(data.data.maxseats);
				 $(".val5").val(data.data.type);
				 $(".val6").val(data.data.widthtype);
			 })
			 $(".sure").click(function(){
				var submitMess = {};
				submitMess.id = $(".id").val();
				submitMess.model = $(".val1").val();
				submitMess.manufacturer = $(".val2").val();
				submitMess.maxWeight = $(".val3").val();
				submitMess.maxseats = $(".val4").val();
				submitMess.type = $(".val5").val();
				submitMess.widthtype = $(".val6").val();
				layer.msg('添加中...', {icon: 16,shade: 0.01});
				$.ajax({
					type:"post",
					url:"../Aircft/edit?temp="+Math.random(),
					contentType:'application/json;charset=utf-8',
					async:true,
					data:JSON.stringify(submitMess),
					success:function(data){
						data=JSON.parse(data)
						if(data.status=="1001"){
							layer.msg('编辑机型成功', {icon: 1,time:1000},function(){
								var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
								parent.layer.close(index);//关闭弹窗
							})	
						}if(data.status=="1002"){
							layer.msg("编辑机型失败,"+data.message,{icon: 2,time:2000},function(){
								
							})
						}
					}
						
				});	
			})
			 
		 }
		//_____________________________________________________________________________新增机型确定
		else{
			$(".sure").click(function(){
				var submitMess = {};
				submitMess.model = $(".val1").val();
				submitMess.manufacturer = $(".val2").val();
				submitMess.maxWeight = $(".val3").val();
				submitMess.maxseats = $(".val4").val();
				submitMess.type = $(".val5").val();
				submitMess.widthtype = $(".val6").val();
				layer.msg('添加中...', {icon: 16,shade: 0.01});
				$.ajax({
					type:"post",
					url:"../Aircft/add?temp="+Math.random(),
					contentType:'application/json;charset=utf-8',
					async:true,
					data:JSON.stringify(submitMess),
					success:function(data){
						data=JSON.parse(data)
						if(data.status=="1001"){
							layer.msg('添加机型成功', {icon: 1,time:1000},function(){
								var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
								parent.layer.close(index);//关闭弹窗
							})	
						}if(data.status=="1002"){
							layer.msg("添加机型失败,"+data.message,{icon: 2,time:2000},function(){
								
							})
						}
					}
						
				});	
			}) 
		}
			 
		//_____________________________________________________________________________新增机型取消
			$(".cancel").click(function(){
				closeWin()
			})	
		
		</script>
		
			
</html>
